package com.atguigu.msmservice.utils;

import com.baomidou.mybatisplus.annotation.Version;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 当项目已启动，spring接口，spring加载之后，执行接口一个方法
 */
@Component
public class MessagePropertiesUtils implements InitializingBean {

    //读取阿里云短信服务配置文件内容
    @Value("${aliyun.msm.file.regionId}")
    private String regionId;

    @Value("${aliyun.msm.file.keyid}")
    private String keyId;

    @Value("${aliyun.msm.file.keysecret}")
    private String keySecret;

    @Value("${aliyun.msm.file.templateCode}")
    private String templateCode;

//    @Value("${aliyun.msm.file.signName}")
//    private String signName;

    @Value("${aliyun.msm.file.msmUrl}")
    private String msmUrl;

    @Value("${aliyun.msm.file.version}")
    private String version;

    @Value("${aliyun.msm.file.methodName}")
    private String methodName;

    //定义公开静态常量
    public static String REGION_ID;
    public static String ACCESS_KEY_ID;
    public static String ACCESS_KEY_SECRET;
    public static String TEMPLATE_CODE;
//    public static String SIGN_NAME;
    public static String MSM_URL;
    public static String VERSION;
    public static String METHOD_NAME;

    @Override
    public void afterPropertiesSet() throws Exception {
        REGION_ID = regionId;
        ACCESS_KEY_ID = keyId;
        ACCESS_KEY_SECRET = keySecret;
        TEMPLATE_CODE = templateCode;
//        SIGN_NAME = signName;
        MSM_URL = msmUrl;
        VERSION = version;
        METHOD_NAME = methodName;
    }
}
